#define _CRT_SECURE_NO_WARNINGS 1

#include<iostream>
#include<algorithm>
using namespace std;
const int N = 1e6 + 10;
int a[N];
int main()
{
    int n, k;
    cin >> n;
    int min2 = 0x3f3f3f3f, flag = 0;
    for (int i = 1;i <= n;i++)
    {
        cin >> a[i];
        if (a[i])
            flag = 1;
        if (a[i] >= 2)
            min2 = min(min2, a[i]);
        if (i == 1)
            k = a[i];
        else
            k = __gcd(a[i], k);
    }
    if (flag == 0)
        cout << 0 << endl;
    else if (min2 == 0x3f3f3f3f || k != 1)
        cout << 1 << endl;
    else
        cout << 2 << endl;
    return 0;
}